package framework;

import impl.persons.*;

/**
 * Date: 21.04.2008
 * Time: 19:26:37
 *
 * @author Denis DIR Rozhnev
 */
public class PersonsFactory {
    private static final String PERSONS_DIR = "impl.persons.";
    public static final String PERSON_EGOIST = "Egoist";
    public static final String PERSON_ALTRUIST = "Altruist";
    public static final String PERSON_TITFORTAT = "TitForTat";
    public static final String PERSON_TRIGGER = "Trigger";
    public static final String PERSON_TRIGGER_WITH_FORGIVENESS = "FTrigger";
    public static final String PERSON_CRAZY_TRIGGER = "CrazyTrigger";
    public static final String PERSON_ANTI_TITFORTAT = "AntiTitForTat";
    public static final String PERSON_WAIT_FOR_GOOD = "WaitForGood";
    public static final String PERSON_DIR = "Dir";
    public static final String PERSON_STUPID = "Stupid";
    public static final int STRATEGIES_COUNT = 10;

    public static Person getPerson(String name) throws Exception {
        return (Person) Class.forName(PERSONS_DIR + name).newInstance();
    }

    public static Person getPerson(int i) {
        switch (i) {
            case 0:
                return new Egoist();
            case 1:
                return new Altruist();
            case 2:
                return new TitForTat();
            case 3:
                return new Trigger();
            case 4:
                return new FTrigger(100);
            case 5:
                return new CrazyTrigger();
            case 6:
                return new AntiTitForTat();
            case 7:
                return new WaitForGood();
            case 8:
                try {
                    return getPerson(PERSON_DIR);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            default:
                return new Stupid();
        }
    }
}
